package kr.hikt.androidcomplete01.ch07;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

public class OffScreen extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyView(this));
	}
	
	class MyView extends View {
		private Paint pnt;
		private Bitmap BackBit;
		private Canvas offscreen;
		
		
		public MyView(Context context) {
			super(context);
			pnt = new Paint();
			BackBit = Bitmap.createBitmap(300, 200, Bitmap.Config.ARGB_8888);
			offscreen = new Canvas(BackBit);
		}

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			canvas.drawColor(Color.LTGRAY);
			
			offscreen.drawColor(Color.GREEN);
			pnt.setColor(Color.RED);
			for( int x= 0; x < 300; x += 10) {
				offscreen.drawLine(x,  0,  300-x, 200, pnt);
			}
			
			canvas.drawBitmap(BackBit, 10, 10, null);
		}
		
		
	}
	
	
}
